
#include <stdio.h>
#include <unistd.h>
#include <linux/getprocinfo.h>
#include "print_task.h"

#define getcurrenttime(arg1, arg2) syscall( 299, arg1, arg2 )


int main() {

  struct proc_info_struct s;
  int ret;


  printf("\nLet's try to crash the kernel by passing in");
  printf("\nbad values!");

  printf("\n\nCalling getprocinfo with a negative pid.");
  ret = getprocinfo( -1, &s );
  printf("\ngetprocinfo returned %d\n", ret);
  perror("getprocinfo: ");

  printf("\n\nCalling getprocinfo with a non-existant pid.");
  ret = getprocinfo( 12345, &s );
  printf("\ngetprocinfo returned %d\n", ret);
  perror("getprocinfo: ");

  printf("\n\nCalling getprocinfo with a NULL pointer.");
  ret = getprocinfo( 0, NULL );
  printf("\ngetprocinfo returned %d\n", ret);
  perror("getprocinfo: ");


  printf("\n\nCalling getprocinfo with a Huge pointer.");
  ret = getprocinfo( 0, 0xffffffffffffffff );
  printf("\ngetprocinfo returned %d\n", ret);
  perror("getprocinfo: ");


  printf("\n\nCalling getcurrenttime with a Huge pointer.");
  ret = getprocinfo( 0, 0xffffffffffffffff );
  printf("\ngetcurrenttime returned %d\n", ret);
  perror("getcurrenttime: ");
  
  printf("\n\nCalling getcurrenttime with a NULL pointer.");
  ret = getcurrenttime( 0, NULL );
  printf("\ngetcurrenttime returned %d\n", ret);
  perror("getcurrenttime: ");


  printf("\nExiting.\n");
  
  return 0;
}
